dbConnection(); $this->conn = $db; } public function runQuery($sql) { $stmt = $this->conn->prepare($sql); return $stmt; } public function lasdID() { $stmt = $this->conn->lastInsertId(); return $stmt; } //update public function stalldetails($reg,$eno,$market,$town,$lga,$msection,$zone,$lineno,$stallno,$stype,$certno,$cdate,$basis,$ansidno,$admin) { try { $td = date("Y-m-d") ; $ttm = date("h:i"); $stmt = $this->conn->prepare("INSERT INTO stall_details(regno,en_no,market,town,lga,market_section,zone,line_no,stall_no,stall_type,alloc_cert_no,cdate,bas_of_occup,ansid_no,admin,dateupdated) VALUES(:a,:b,:c,:d,:e,:f,:g,:h,:i,:j,:k,:l,:m,:n,:o,:p)"); $stmt->bindparam(":a",$reg); $stmt->bindparam(":b",$eno); $stmt->bindparam(":c",$market); $stmt->bindparam(":d",$town); $stmt->bindparam(":e",$lga); $stmt->bindparam(":f",$msection); $stmt->bindparam(":g",$zone); $stmt->bindparam(":h",$lineno); $stmt->bindparam(":i",$stallno); $stmt->bindparam(":j",$stype); $stmt->bindparam(":k",$certno); $stmt->bindparam(":l",$cdate); $stmt->bindparam(":m",$basis); $stmt->bindparam(":n",$ansidno); $stmt->bindparam(":o",$admin); $stmt->bindparam(":p",$td); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function insertaddress($user,$res,$office,$phone,$emails,$code) { try { $stmt = $this->conn->prepare("INSERT INTO address(user_id,residence,office,phoneno,emails,tokenCode) VALUES(:fn,:ln,:cm,:ph,:cnt,:cd)"); $stmt->bindparam(":fn",$user); $stmt->bindparam(":ln",$res); $stmt->bindparam(":cm",$office); $stmt->bindparam(":ph",$phone); $stmt->bindparam(":cnt",$emails); $stmt->bindparam(":cd",$code); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function biodata($reg,$cname,$creg,$mid,$idno,$nat,$astate,$lga,$phone,$emails,$office,$admin) { $td = date("Y-m-d") ; try { $stmt = $this->conn->prepare("INSERT INTO allotee_biodata(regno,custodian,company_regno,identification_means,id_no,nationality,state,lga,allote_phone,allote_email,allote_office,admin,dateupdated) VALUES(:a,:b,:c,:d,:e,:f,:g,:h,:i,:j,:k,:l,:m)"); $stmt->bindparam(":a",$reg); $stmt->bindparam(":b",$cname); $stmt->bindparam(":c",$creg); $stmt->bindparam(":d",$mid); $stmt->bindparam(":e",$idno); $stmt->bindparam(":f",$nat); $stmt->bindparam(":g",$astate); $stmt->bindparam(":h",$lga); $stmt->bindparam(":i",$phone); $stmt->bindparam(":j",$emails); $stmt->bindparam(":k",$office); $stmt->bindparam(":l",$admin); $stmt->bindparam(":m",$td); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function nextkin($reg,$name,$relation,$nphone,$admin) { $td = date("Y-m-d") ; try { $stmt = $this->conn->prepare("INSERT INTO nextofkin(regno,names,relationship,phoneno,admin,dateupdated) VALUES(:a,:b,:c,:d,:e,:f)"); $stmt->bindparam(":a",$reg); $stmt->bindparam(":b",$name); $stmt->bindparam(":c",$relation); $stmt->bindparam(":d",$nphone); $stmt->bindparam(":e",$admin); $stmt->bindparam(":f",$td); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function tax($user,$yr,$val) { try { $stmt = $this->conn->prepare("INSERT INTO taxation(user_id,year,value) VALUES(:fn,:ln,:cm)"); $stmt->bindparam(":fn",$user); $stmt->bindparam(":ln",$yr); $stmt->bindparam(":cm",$val); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function monitor($activities) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO monitor(activities) VALUES(:fn)"); $stmt->bindparam(":fn",$activities); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function createabout($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO about(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function createvision($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO vision(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function pubnews($cont) { try { $adate = date("Y-m-d") ; $stmt = $this->conn->prepare("INSERT INTO news(content,newsdate) VALUES(:fn,:b)"); $stmt->bindparam(":fn",$cont); $stmt->bindparam(":b",$adate); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatenews($cont,$sn) { try { $stmt = $this->conn->prepare("update news set content =:cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function createmission($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO mission(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function createtarget($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO target(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function creategoals($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO goals(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function createhow($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO how(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function createwelcome($cont) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO welcome(content) VALUES(:fn)"); $stmt->bindparam(":fn",$cont); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function subscribe($mail) { try { //$at = date("Y-m-d","h:i:sa") ; $stmt = $this->conn->prepare("INSERT INTO subscribers(emails) VALUES(:fn)"); $stmt->bindparam(":fn",$mail); //$stmt->bindparam(":at",$at); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function publishgallery($title,$image) { try { $stmt = $this->conn->prepare("INSERT INTO gallery(caption,image) VALUES(:un,:ct)"); $stmt->bindparam(":un",$title); $stmt->bindparam(":ct",$image); //$stmt->bindparam(":lg",$lga); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatecontent($cont,$sn) { try { $stmt = $this->conn->prepare("update about set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatehow($cont,$sn) { try { $stmt = $this->conn->prepare("update how set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatewelcome($cont,$sn) { try { $stmt = $this->conn->prepare("update welcome set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatevision($cont,$sn) { try { $stmt = $this->conn->prepare("update vision set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatemission($cont,$sn) { try { $stmt = $this->conn->prepare("update mission set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatetarget($cont,$sn) { try { $stmt = $this->conn->prepare("update target set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updategoals($cont,$sn) { try { $stmt = $this->conn->prepare("update goals set content = :cn where sn =:sno"); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sn); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updateadmin($usa,$level,$sno) { try { $stmt = $this->conn->prepare("update admin set LEVEL = :lv, USERNAME = :us where SN =:sno"); $stmt->bindparam(":lv",$level); $stmt->bindparam(":sno",$sno); $stmt->bindparam(":us",$usa); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function changepassword($user,$pwd) { try { $rp = md5($pwd) ; $stmt = $this->conn->prepare("update stalldata set pwd = :pd where user_id =:u"); $stmt->bindparam(":pd",$rp); $stmt->bindparam(":u",$user); //$stmt->bindparam(":us",$usa); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatemarket($mark,$cat,$sno) { try { $stmt = $this->conn->prepare("update markets set NAMES = :lv,category=:cat where SN =:sno"); $stmt->bindparam(":lv",$mark); $stmt->bindparam(":cat",$cat); $stmt->bindparam(":sno",$sno); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatecategory($name,$cont,$sno) { try { $stmt = $this->conn->prepare("update category set category_name = :c,content=:cn where sn =:sno"); $stmt->bindparam(":c",$name); $stmt->bindparam(":cn",$cont); $stmt->bindparam(":sno",$sno); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updatecontacts($add,$mail,$phone,$snm) { try { $stmt = $this->conn->prepare("update contacts set physical = :lv,emails=:ml, phoneno =:ph where sn =:sno"); $stmt->bindparam(":lv",$add); $stmt->bindparam(":ml",$mail); $stmt->bindparam(":ph",$phone); $stmt->bindparam(":sno",$snm); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function updateevents($cat,$title,$date1,$date2,$tms,$ds,$ven,$sno ) { try { $stmt = $this->conn->prepare("update events set category = :ct,title=:tt, begin_date = :dt1, end_date =:dt2, time=:tm, dsc =:ds, venue =:ven where sn =:sno"); $stmt->bindparam(":ct",$cat); $stmt->bindparam(":tt",$title); $stmt->bindparam(":dt1",$date1); $stmt->bindparam(":dt2",$date2); $stmt->bindparam(":tm",$tms); $stmt->bindparam(":ds",$ds); $stmt->bindparam(":ven",$ven); $stmt->bindparam(":sno",$sno); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function create($user,$pwd,$mail,$level,$code) { try { $password = md5($pwd); $stmt = $this->conn->prepare("INSERT INTO admin(USERNAME,PASSWORD,EMAILS,LEVEL,tokenCode) VALUES(:un,:pw,:mls,:lev,:cd)"); $stmt->bindparam(":un",$user); $stmt->bindparam(":pw",$password); $stmt->bindparam(":mls",$mail); $stmt->bindparam(":lev",$level); $stmt->bindparam(":cd",$code); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function add_contacts($phy,$emails,$phone) { try { $stmt = $this->conn->prepare("INSERT INTO contacts(physical,emails,phoneno) VALUES(:a,:b,:c)"); $stmt->bindparam(":a",$phy); $stmt->bindparam(":b",$emails); $stmt->bindparam(":c",$phone); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function regmembers($title,$names,$nick,$pos,$country,$phone,$emails,$gender) { try { $image = 'image' ; $stmt = $this->conn->prepare("INSERT INTO members(title,fullname,nickname,position,country,phone,email,gender,image) VALUES(:a,:b,:c,:d,:e,:f,:g,:h,:i)"); $stmt->bindparam(":a",$title); $stmt->bindparam(":b",$names); $stmt->bindparam(":c",$nick); $stmt->bindparam(":d",$pos); $stmt->bindparam(":e",$country); $stmt->bindparam(":f",$phone); $stmt->bindparam(":g",$emails); $stmt->bindparam(":h",$gender); $stmt->bindparam(":i",$image); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function application($title,$names,$phone,$emails,$country) { try { $stmt = $this->conn->prepare("INSERT INTO apply(title,names,phone,emails,country) VALUES(:a,:b,:c,:d,:e)"); $stmt->bindparam(":a",$title); $stmt->bindparam(":b",$names); $stmt->bindparam(":c",$phone); $stmt->bindparam(":d",$emails); $stmt->bindparam(":e",$country); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function Publishevents($cat,$title,$date1,$date2,$times,$ds,$venue) { try { $fly = "image" ; $stmt = $this->conn->prepare("INSERT INTO events(category,title,begin_date,end_date,time,dsc,venue,flyer) VALUES(:ct,:tt,:dt1,:dt2,:tm,:ds,:vn,:fy)"); $stmt->bindparam(":ct",$cat); $stmt->bindparam(":tt",$title); $stmt->bindparam(":dt1",$date1); $stmt->bindparam(":dt2",$date2); $stmt->bindparam(":tm",$times); $stmt->bindparam(":ds",$ds); $stmt->bindparam(":vn",$venue); $stmt->bindparam(":fy",$fly); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function Publishaward($title,$ds,$adate) { try { $fly = "image" ; $stmt = $this->conn->prepare("INSERT INTO awards(award_name,details,adate,image) VALUES(:a,:b,:c,:d)"); $stmt->bindparam(":a",$title); $stmt->bindparam(":b",$ds); $stmt->bindparam(":c",$adate); $stmt->bindparam(":d",$fly); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function registermarket($lga,$cat,$names,$img) { try { $stmt = $this->conn->prepare("INSERT INTO markets(lga,category,NAMES,images) VALUES(:lg,:un,:ct,:img)"); $stmt->bindparam(":un",$cat); $stmt->bindparam(":ct",$names); $stmt->bindparam(":lg",$lga); $stmt->bindparam(":img",$img); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function sumitdocument($regno,$dname,$img) { try { $stmt = $this->conn->prepare("INSERT INTO documents(regno,doc_name,image) VALUES(:a,:b,:c)"); $stmt->bindparam(":a",$regno); $stmt->bindparam(":b",$dname); $stmt->bindparam(":c",$img); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function marketsection($names,$sec) { try { $stmt = $this->conn->prepare("INSERT INTO marketsection(market,section) VALUES(:un,:ct)"); $stmt->bindparam(":un",$names); $stmt->bindparam(":ct",$sec); //$stmt->bindparam(":lg",$lga); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function regcategory($names,$cont) { try { $stmt = $this->conn->prepare("INSERT INTO category(category_name,content) VALUES(:un,:cn)"); $stmt->bindparam(":un",$names); $stmt->bindparam(":cn",$cont); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function neworder($orderno,$item,$desc,$quant,$origin,$dest) { try { $tdate = date("Y/m/d") ; $sdate = date("l") ; $ldate = $sdate.'--'.$tdate ; $sts = 'NOT DELIVERD YET' ; $cl = 'OFFICE' ; $ttm = date("h:i"); $stmt = $this->conn->prepare("INSERT INTO trans(longsdate,transdate,order_no,items,descripts,quantity,origin,destination,curent_location,status,transtime) VALUES(:lt,:td,:odn,:itm,:ds,:qun,:org,:dst,:cln,:stu,:tt)"); $stmt->bindparam(":lt",$ldate); $stmt->bindparam(":td",$tdate); $stmt->bindparam(":odn",$orderno); $stmt->bindparam(":itm",$item); $stmt->bindparam(":ds",$desc); $stmt->bindparam(":qun",$quant); $stmt->bindparam(":org",$origin); $stmt->bindparam(":dst",$dest); $stmt->bindparam(":cln",$cl); $stmt->bindparam(":stu",$sts); $stmt->bindparam(":tt",$ttm); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function create_blog($fnames,$gend,$uname,$email,$upass,$code,$phone) { try { $password = md5($upass); $stmt = $this->conn->prepare("INSERT INTO pblog(fname,gender,userName,userEmail,userPass,tokenCode,phone) VALUES(:fn,:gen,:user_name, :user_mail, :user_pass, :active_code,:ph)"); $stmt->bindparam(":fn",$fnames); $stmt->bindparam(":gen",$gend); $stmt->bindparam(":user_name",$uname); $stmt->bindparam(":user_mail",$email); $stmt->bindparam(":user_pass",$password); $stmt->bindparam(":active_code",$code); $stmt->bindparam(":ph",$phone); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function loginact($email,$upass) { try { $stmt = $this->conn->prepare("SELECT * FROM pblog WHERE userEmail=:email_id"); $stmt->execute(array(":email_id"=>$email)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($stmt->rowCount() == 1) { //if($userRow['userStatus']=="Y") //{ if($userRow['userPass']==md5($upass)) { $_SESSION['userSession'] = $userRow['userName']; //$_SESSION['usermail'] = $userRow['userEmail']; $_SESSION['userID'] = $userRow['userID']; $_SESSION['loggedin'] = true; return true; } else { header("Location: account.php?error"); exit; } //} //else //{ //header("Location: acount.php?inactive"); //exit; //} } else { header("Location: account.php?error"); exit; } } catch(PDOException $ex) { echo $ex->getMessage(); } } public function login($user,$upass) { try { $stmt = $this->conn->prepare("SELECT * FROM stalldata WHERE user_id =:user"); $stmt->execute(array(":user"=>$user)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($stmt->rowCount() == 1) { if($userRow['pwd']==md5($upass)) { //$_SESSION['userSession'] = $userRow['cemail']; $_SESSION['username'] = $userRow['user_id']; return true; } else { header("Location: login.php?errorp"); exit; } } else { header("Location: login.php?errore"); exit; } } catch(PDOException $ex) { echo $ex->getMessage(); } } public function loginadmin($user,$upass) { try { $stmt = $this->conn->prepare("SELECT * FROM admin WHERE USERNAME =:email_id"); $stmt->execute(array(":email_id"=>$user)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($stmt->rowCount() == 1) { if($userRow['PASSWORD']==md5($upass)) { $_SESSION['userSession'] = $userRow['USERNAME']; $_SESSION['username'] = $userRow['USERNAME']; $_SESSION['lv'] = $userRow['LEVEL']; return true; } else { header("Location: ../admin/login?errorp"); exit; } } else { header("Location: ../admin/login?errore"); exit; } } catch(PDOException $ex) { echo $ex->getMessage(); } } public function change_password($emails,$pass) { try { $password = md5($pass); $stmt = $this->conn->prepare("update customers set pwd =:pd where cemails =:ml"); $stmt->bindparam(":pd",$password); $stmt->bindparam(":ml",$emails); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function change_pwd($emails,$pass) { try { $password = md5($pass); $stmt = $this->conn->prepare("update admin set PASSWORD =:pd where USERNAME =:ml"); $stmt->bindparam(":pd",$password); $stmt->bindparam(":ml",$emails); $stmt->execute(); return $stmt; } catch(PDOException $ex) { echo $ex->getMessage(); } } public function is_logged_in() { if(isset($_SESSION['userSession'])) { return true; } } public function redirect($url) { header("Location: $url"); } public function logout() { session_destroy(); $_SESSION['userSession'] = false; } function send_mail($email,$message,$subject) { require_once('mailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 0; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = "titano.protonhosting.com"; $mail->Port = 465; $mail->AddAddress($email); $mail->Username="info@ansmaportal.com"; $mail->Password="ansma@2020"; $mail->SetFrom('info@ansmaportal.com','MARKET_DEVELOPEMENT'); $mail->AddReplyTo("info@ansmaportal.com","MARKET_DEVELOPEMENT"); $mail->Subject = $subject; $mail->MsgHTML($message); $mail->Send(); } }